#include "Frog.h"
#include "FrogSketcher.h"

Frog::Frog() {
	this->setType("Frog");
}

Frog::Frog(Position *position) {
	this->setPosition(position);
}

Frog::Frog(Position *position,float radius) {
	this->setRadius(radius);
	Frog::Frog(position);
}

Frog::Frog(Position *position,float radius,Color * color) {
	this->setElementColor(color);
	Frog::Frog(position,radius);
}

Frog::Frog(Position *position,float radius,Texture *texture) {
	this->setTexture(texture);
	Frog::Frog(position,radius);
}


/*-------------Getters & Setters--------------------*/
void Frog::setPosition(Position *position){
	this->position = position;
}

Position *Frog::getPosition(){
	return this->position;
}

Color * Frog::getElementColor(){
	return this->elementColor;
}

void Frog::setElementColor(Color * color){
	this->elementColor = color;
}

float Frog::getRadius(){
	return this->radius;
}

void Frog::setRadius(float radius){
	this->radius = radius;
}

Texture *Frog::getTexture(){
	return this->texture;
}

void Frog::setTexture(Texture *texture){
	this->texture = texture;
}

void Frog::setMainBall(Ball *ball){
	this->mainBall = ball;
}

void Frog::setSecondaryBall(Ball *ball){
	this->secondaryBall = ball;
}

Ball * Frog::getMainBall(){
	return this->mainBall;
}

Ball * Frog::getSecondaryBall(){
	return this->secondaryBall;
}

float Frog::getMinXPos(){
	return this->getPosition()->getAxisX()-this->radius;
}

float Frog::getMinYPos(){	
	return this->getPosition()->getAxisY()-this->radius;
}

float Frog::getMaxXPos(){	
	return this->getPosition()->getAxisX()+this->radius;
}

float Frog::getMaxYPos(){
	return this->getPosition()->getAxisY()+this->radius;
}

Color * Frog::getLineColor() {
	return this->lineColor;
}

void Frog::setLineColor( Color * color ) {
	this->lineColor = color;
}


/*---------------Metodos----------------------------*/
void Frog::draw() {
	Sketcher* sketcher = new FrogSketcher(this);
	this->initialiceBalls();
	sketcher->draw();
	delete(sketcher);
}

/*Este metodo deberia ser ejecutado al inicializar el sapo*/
void Frog::initialiceBalls(){
	
	this->mainBall = new Ball(this->position);
	/*Decidir de donde sacar los colores*/
	this->mainBall->setElementColor(new Color("200","150","10"));
	this->mainBall->setLineColor(new Color("0","0","0"));
	/*Decidir de donde se saca el radio de la bola y borrar esto*/
	this->mainBall->setRadius(15);

	/*Definir position de la bola secundaria*/
	Position *position = new Position(this->position->getAxisX(),this->position->getAxisY()-5);
	this->secondaryBall = new Ball(position);
	this->secondaryBall->setElementColor(new Color("200","150","10"));
	this->secondaryBall->setLineColor(new Color("0","0","0"));
	/*Decidir de donde se saca el radio de la bola y borrar esto*/
	this->secondaryBall->setRadius(15);
}

void Frog::reBuildBalls(){
	this->mainBall = secondaryBall;
	Position *position = new Position(this->position->getAxisX(),this->position->getAxisY()-5);
	this->secondaryBall = new Ball(this->position);
	/*Decidir de donde sacar los colores*/
	this->secondaryBall->setElementColor(new Color("200","150","10"));
	this->secondaryBall->setLineColor(new Color("0","0","0"));
	this->secondaryBall->setRadius(15);
}

/*---------------Destructor----------------------------*/

Frog::~Frog() {
	delete(this->texture);
	delete(this->position);
	delete(this->mainBall);
	delete(this->secondaryBall);
}